package com.ctcemti.mdm.project.sys.service.impl;

import com.ctcemti.mdm.project.sys.dao.InfDictItemMapper;
import com.ctcemti.mdm.project.sys.entity.InfDictItem;
import com.ctcemti.mdm.project.sys.service.InfDictItemService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;

import java.util.List;
import java.util.Map;

@Service
public class InfDictItemServiceImpl implements InfDictItemService {
    
    @Autowired
    private InfDictItemMapper infDictItemMapper;


    @Transactional
    @Override
    public int deleteByPrimaryKey(Integer id) {
        return infDictItemMapper.deleteByPrimaryKey(id);
    }

    @Transactional
    @Override
    public int insert(InfDictItem record) {
        return infDictItemMapper.insert(record);
    }

    @Transactional
    @Override
    public int insertSelective(InfDictItem record) {
        return infDictItemMapper.insertSelective(record);
    }

    @Override
    public InfDictItem selectByPrimaryKey(Integer id) {
        return infDictItemMapper.selectByPrimaryKey(id);
    }

    @Transactional
    @Override
    public int updateByIdSelective(InfDictItem record) {
        return infDictItemMapper.updateByIdSelective(record);
    }

    @Transactional
    @Override
    public int updateByPrimaryKey(InfDictItem record) {
        return infDictItemMapper.updateByPrimaryKey(record);
    }

    @Override
    public List<InfDictItem> selectAllInfDictItem() {
        return infDictItemMapper.selectAll();
    }

    @Override
    public List<InfDictItem> selectByPid(String s) {
        Example example = new Example(InfDictItem.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("pid",s);
        return infDictItemMapper.selectByExample(example);
    }

    @Override
    public List<InfDictItem> selectInfDictItem(InfDictItem InfDictItem) {
        return infDictItemMapper.select(InfDictItem);
    }

    @Transactional
    @Override
    public int deleteByPrimaryKeys(String ids) {
        return infDictItemMapper.deleteByIds(ids);
    }

    @Override
    public PageInfo<Map<String,Object>> selectListByPid(InfDictItem infDictItem) {
        PageHelper.startPage(infDictItem.getPageIndex(),infDictItem.getPageSize(),"idi.sort");
        List<Map<String,Object>> list = infDictItemMapper.selectMapByPid(infDictItem.getId().toString());
        PageInfo<Map<String,Object>> pageInfo =  new PageInfo<Map<String,Object>>(list);
        return pageInfo;
    }
    @Override
    public List<InfDictItem> selectInfdictitemByInfdictsortCode(String code){
        return infDictItemMapper.selectInfdictitemByInfdictsortCode(code);
    }
}
